﻿//
// Created by Freeman on 2022/4/13.
//

#ifndef DATA_STRUCTURE_REVIEW_MAT_GRAPH_HPP
#define DATA_STRUCTURE_REVIEW_MAT_GRAPH_HPP

#include <climits>
#include <utility>
#include <vector>

#include "Edge.hpp"

/**
 * 使用邻接矩阵的带权图的图的基类
 */
class WeightedMatGraph {
protected:
    const int nVex;                         // 顶点数量

public:
    std::vector<std::vector<int>> adjMat;   // 邻接矩阵

public:
    explicit WeightedMatGraph(int nVex) : nVex(nVex), adjMat(nVex, std::vector<int>(nVex, INT_MAX)) {
        for (int v = 0; v < nVex; v++) {
            adjMat[v][v] = 0;
        }
    }

    explicit WeightedMatGraph(std::vector<std::vector<int>> adjMat) : nVex(adjMat.size()), adjMat(std::move(adjMat)) {}

    /**
     * 添加边
     * @param tail 边尾，边开始的顶点
     * @param head 边头，边指向的顶点
     * @param weight 边的权重
     */
    virtual void addEdge(int tail, int head, int weight) = 0;
};

#endif //DATA_STRUCTURE_REVIEW_MAT_GRAPH_HPP
